/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.postbar.entity;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

/**
 *
 * @author xiaoliang
 */
public class MongoDB {
    private String hosts;
    private String user;
    private String passwd;
    private String table;
    private List<String> hostList;
    private String db;
    
//    old_mongo_hosts=10.136.139.22:23456;10.136.139.21:23456;10.136.139.23:23456;
//    old_mongo_user=w123
//    old_mongo_passwd=w123
//    old_mongo_db=docinfo
//    old_mongo_table=docinfo

    public MongoDB(String phosts, String user, String passwd, String db, String table) {
        this.db = db;
        this.hosts = phosts;
        this.user = user;
        this.passwd = passwd;
        this.table = table;
        List<String> hostListp = new ArrayList<>();
        String [] hostAll = phosts.split(";");
        hostListp.addAll(Arrays.asList(hostAll));
        this.hostList = hostListp;
    }

    public String getUser() {
        return user;
    }

    public String getPasswd() {
        return passwd;
    }

    public String getTable() {
        return table;
    }
    
    public String getHost(){
        Random r = new Random();
        return hostList.get(r.nextInt(hostList.size()));
    }

    public String getDb() {
        return db;
    }
    
}
